package threadPool;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author: 李德才
 * @description:
 * @create: 2020-12-19 20:20
 **/
public class T06_FutureTask {

    public static void main(String[] args) throws ExecutionException, InterruptedException {

        /**
         * public class FutureTask<V> implements RunnableFuture<V>
         *
         * public interface RunnableFuture<V> extends Runnable, Future<V> {
         *
         * FutureTask 间接实现了 Runnable Future，同时具有两个类的功能
         */
        FutureTask<Integer> futureTask = new FutureTask<>(() ->{
            System.err.println("Callable");
            return 1;
        });
        new Thread(futureTask).start();
        System.err.println(futureTask.get());
    }


}
